﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace OnlineMealOrdering.Extends.Attributes
{
    //test result:web page cache can not work, and cache is private instead of public, and web page get new content instead of old content
    //public class CacheFilterAttribute:ActionFilterAttribute
    //{
    //    public int Duration { get; set; }

    //    public CacheFilterAttribute()
    //    {
    //        Duration = 10;
    //    }

    //    public override void OnActionExecuted(ActionExecutedContext filterContext)
    //    {
    //        if (Duration <= 0) return;

    //        HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache;
    //        TimeSpan cacheDuration = TimeSpan.FromSeconds(Duration);
    //        cache.SetCacheability(HttpCacheability.Public);
    //        cache.SetExpires(DateTime.Now.Add(cacheDuration));
    //        cache.SetMaxAge(cacheDuration);
    //        cache.AppendCacheExtension("must-revalidate,proxy-revalidate");
    //    }

    //}
}
